<?

	/*
	 * All hooked functions are sent the parameters $server (The server class), $client (the connection), and $input (anything sent, if anything was sent)
	 * You should save the variables $server and $client using an ampersand (&) to make sure they are references to the objects and not duplications.
	 */
	function handle_connect(&$server,&$client,$input)
	{
	   SocketServer::socket_write_smart($client->socket,"Handle_connect ",""); // Request Another String
		SocketServer::socket_write_smart($client->socket,"String? ",""); // Outputs 'String? ' without a Line Ending
        
	}
    
	function handle_input(&$server,&$client,$input)
	{
        $objLogger=new Logger();
		$objLogger->write_log("[Functions - handle_input] handle ");          //FD Debug
        
        $trim = trim($input); // Trim the input, Remove Line Endings and Extra Whitespace.
 
		if(strtolower($trim) == "quit") // User Wants to quit the server
		{
		    $objLogger->write_log("[Functions - handle_input] quiting.. GoodBye ");
			SocketServer::socket_write_smart($client->socket,"Oh... Goodbye..."); // Give the user a sad goodbye message, meany!
			$server->disconnect($client->server_clients_index); // Disconnect this client.
			return; // Ends the function
		}
 
		$output = strrev($trim); // Reverse the String
        
        $objLogger->write_log("[Functions - handle_input] DATA: ".$output);        //FD Debug   
        /////////ACA SE ENVIAN Los DATOS        
        SocketServer::socket_write_smart($client->socket,"Handle_input "); // FD
		SocketServer::socket_write_smart($client->socket,$output); // Send the Client back the String
		SocketServer::socket_write_smart($client->socket,"String? ",""); // Request Another String
        
	}
?>